package com.asialjim.wechat.apiservice.exception;

import com.asialjim.wechat.apiservice.enumeration.WeChatApiReturnEnumeration;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <h1><em>ASIAL JIM JAVA DOC</em></h1><hr/>
 * <h2>CLASS DESCRIPTION <i>[ NAME: WeChatApiException ]</i></h2><strong>
 * <p> we chat exception
 * </strong><p><p><em>Copyright &copy; Asial Jim Co., LTD</em><hr/>
 *
 * @author Asial Jim &nbsp;&nbsp; <span>Email:<a href="mailto:asialjim@hotmail.com">asialjim@hotmail.com</a> &nbsp;&nbsp; <a href="asialjim@qq.com">asialjim@qq.com</a></span>
 * @version 1.0.0
 * @since 2021/1/27   &nbsp;&nbsp; JDK 8
 */
@Data
@EqualsAndHashCode(callSuper = false)
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class WeChatApiException extends RuntimeException {

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * exception code
     */
    private String code;

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * exception message
     */
    private String message;

    /**
     * <h3>FIELD DESCRIPTION</h3>
     * exception system message
     */
    private String systemMessage;

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: cast ]</i></h3>
     * cast exception
     * @param code {@link String code}

     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/2/27 11:15
     */
    public static void cast(String code){ cast(code,null); }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: cast ]</i></h3>
     * cast exception
     * @param code {@link String code}
     * @param message {@link String message}

     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/2/27 11:15
     */
    public static void cast(String code,String message){ cast(code,message,null); }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: cast ]</i></h3>
     * cast exception
     * @param code {@link String code}
     * @param message {@link String message}
     * @param systemMessage {@link String system message}

     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/2/27 11:16
     */
    public static void cast(String code,String message,String systemMessage){ throw create(code, message, systemMessage); }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: cast ]</i></h3>
     * cast exception
     * @param weChatApiReturnEnumeration {@link WeChatApiReturnEnumeration we chat api return enumeration}

     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/2/27 11:16
     */
    public static void cast(WeChatApiReturnEnumeration weChatApiReturnEnumeration){ cast(String.valueOf(weChatApiReturnEnumeration.getCode()),weChatApiReturnEnumeration.getMessage()); }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: create ]</i></h3>
     * create we chat exception
     * @param code {@link String error code}
     * @return {@link WeChatApiException exception}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/2/28 15:28
     */
    public static WeChatApiException create(String code){ return create(code,null); }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: create ]</i></h3>
     * create we chat exception
     * @param code {@link String error code}
     * @param message {@link String error message}
     * @return {@link WeChatApiException exception}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/2/28 15:28
     */
    public static WeChatApiException create(String code, String message){
        return create(code,message,null);
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: create ]</i></h3>
     * create we chat exception
     * @param code {@link String code}
     * @param message {@link String error message}
     * @param systemMessage {@link String system error message}
     * @return {@link WeChatApiException exception}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/2/28 15:29
     */
    public static WeChatApiException create(String code, String message, String systemMessage){
        return new WeChatApiException(code, message, systemMessage);
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: create ]</i></h3>
     * create we chat exception
     * @param apiReturn {@link WeChatApiReturnEnumeration we chat api return enumeration}
     * @return {@link WeChatApiException exception}
     * @author Asial Jim &nbsp;&nbsp;<span>Email:asialjim@hotmail.com &nbsp;&nbsp; asialjim@qq.com</span>
     * @since 2021/2/28 15:29
     */
    public static WeChatApiException create(WeChatApiReturnEnumeration apiReturn){
        return create(String.valueOf(apiReturn.getCode()),apiReturn.getMessage());
    }

    /**
     * <h3>METHOD DESCRIPTION <i>[ NAME: create ]</i></h3>
     * create we chat exception
     * @param apiReturn {@link WeChatApiReturnEnumeration we chat api return enumeration}
     * @param systemMessage {@link String system message}
     * @return {@link WeChatApiException exception}
     * @author Asial Jim &nbsp;&nbsp; <span>Email: &nbsp;&nbsp; <a href="mailto:asialjim@hotmail.com">asialjim@hotmail.com</a> &nbsp;&nbsp; <a href="asialjim@qq.com">asialjim@qq.com</a></span>
     * @since 2021/3/3 13:47
     */
    public static WeChatApiException create(WeChatApiReturnEnumeration apiReturn, String systemMessage){
        return create(String.valueOf(apiReturn.getCode()),apiReturn.getMessage(),systemMessage);
    }
}
